<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/global/jsp-header.jsp"%>
<c:set var="workerQueryVisable" value="${d:accessUri('/worker/worker-query.do',pageContext.request) }"></c:set>
<c:set var="workerAddVisable" value="${d:accessUri('/worker/worker-add.do',pageContext.request) }"></c:set>
<c:set var="workerDeleteVisable" value="${d:accessUri('/worker/worker-delete.do',pageContext.request) }"></c:set>
<c:set var="workerEditVisable" value="${d:accessUri('/worker/worker-edit.do',pageContext.request) }"></c:set>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html">
		<title>员工管理</title>
		<%@ include file="/global/html-header.jsp"%>
	<script type="text/javascript">
		$(function() {
			<c:if test="${workerQueryVisable}">
			$("#myform").submit();
			</c:if>
			common.validator("myform");
			common.initDialog("message-dialog");
			common.initDelDialogMsg("确定要删除此员工？");
			<c:if test="${workerAddVisable}">
			$("#addWorker").on("click",function(){
				$("#addorupdate-dialog").wijdialog({ width: 1200, height: 600, contentUrl: '/worker/worker-addorupdate.do?operationType=insert', autoOpen: true,modal : true,title:"新增员工" });
			});
			</c:if>
			$("#delete-dialog").wijdialog({
	            autoOpen: false,
	            resizable: false,
	            height: 200,
	            width: 320,
	            modal: true,
	            title:'删除员工',
	            buttons: {
	                "确定": function () {
	                	if(!$("#delete-dialog").attr("operaterId")){
	                		return false;
	                	}
	                	<c:if test="${workerDeleteVisable}">
	                	var delWorkerId=$("#delete-dialog").attr("operaterId");
	                	$.ajax({   
	                		type: "POST",  
	                		url: "/worker/worker-delete.do",  
	                		data: ({"worker.workerId":delWorkerId}), 
	                		success: function(msg){    
	                			if(msg=="success"){
	                				$("#msgcontent").html("员工删除成功！");
	                				$("#queryResultIframe").contents().find("tr[workerId='"+delWorkerId+"']'").remove();
	                			}else{
	                				$("#msgcontent").html("员工删除失败！");
	                			}
	                			common.tipWithAutoClose("message-dialog");
	                		} 
	                	});
	                    $(this).wijdialog("close");
	                    </c:if>
	                },
	                "取消": function () {
	                    $(this).wijdialog("close");
	                }
	            }
	        });
		});
		//删除员工窗口弹出
		function deleteDivOpen(workerId){
			$('#delete-dialog').wijdialog('open');
			$('#delete-dialog').attr("operaterId",workerId);
		}
		
		<c:if test="${workerEditVisable}">
		function editWorkerTip(msg){
			$("#msgcontent").html(msg);
			common.tipWithAutoClose("message-dialog");
		}
		
		function editDivOpen(workerId){
			$("#addorupdate-dialog").wijdialog({ width: 1200, height: 600, contentUrl: '/worker/worker-addorupdate.do?operationType=update&worker.workerId='+workerId, autoOpen: true,modal : true,title:"编辑员工" });
		}
		</c:if>
		function closeDialog(){
			$("#addorupdate-dialog").wijdialog('close');
		}
		</script>
	</head>
	<body>
		<div class="container ">
			<div class="content">
				<form action="/worker/worker-query.do" name="myform" class="myform"
					id="myform" target="queryResultIframe" method="post">
					<div class="leftDiv m25" style="width:60%;">
						<div>
							<jsp:include page="/global/organ.jsp">
								<jsp:param name="workerId" value="${currentWorker.workerId}"/>
								<jsp:param name="uri" value="/worker/worker-query.do"/>
								<jsp:param name="deptName" value="param.deptId"/>
								<jsp:param name="groupName" value="param.groupId"/>
								<jsp:param name="noWorker" value="1"/>
								<jsp:param name="defaultValue" value=" "/>
								<jsp:param name="otherAttr" value="style='width: 153px;' "/>
							</jsp:include>
						</div>
						<div>
							<label >
								员工编号:
							</label>
							<input type="text" size="40" name="param.workerId" class="digits" />
						</div>
						<div>
							<label >
								员工名称:
							</label>
							<input type="text" size="40" name="param.workerName"/>
						</div>
						<div>
							<label >
								员工职能:
							</label>
							<input type="text" size="40" name="param.rank"	class="digits" />
						</div>
						<div>
							<label>
								&nbsp;
							</label>
							<c:if test="${workerQueryVisable}">
							<input type="submit" value="提交" />
							<input type="reset" value="重置" />
							</c:if>
							<c:if test="${workerAddVisable}">
							<input type="button" id="addWorker" value="新增" />
							<em class="ideal-button" style="visibility:hidden;"></em>
							</c:if>
						</div>
					</div>
				</form>
			</div>
			<div class="content hide" id="queryResult">
				<iframe class="queryResultIframe" name="queryResultIframe"
					id="queryResultIframe" src="about:blank" style="width: 97%;"
					frameborder="0" scrolling="no"></iframe>
			</div>
		</div>
		<%@ include file="/global/common-dialog.jsp" %>
	</body>
</html>